﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FineUICore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using QuDao;

namespace AdminUI.Pages.SysManage
{
    public partial class MenuEditModel : BaseModel
    {
        public void OnGet(int id)
        {
            Current = MenuBO.Instance.GetItem<MenuDto>(id);

            if (Current != null && Current.ParentID > 0)
            {
                var parent = MenuBO.Instance.GetItem(Current.ParentID);
                if(parent != null) ParentName = $"{parent.MenuID}-{parent.MenuName}";
            }
        }

        public MenuDto Current { get; set; }
        public string ParentName { get; set; } = "0-顶层菜单";

        public IActionResult OnPostBtnSubmit_Click(MenuDto dto)
        {
            MenuBO.Instance.Modify(dto);
            //LogAction(ActionType.ÐÞ¸Ä, $"ÐÞ¸Ä²Ëµ¥£º{dto.MenuID}-{dto.MenuName}");

            //FineUICore.PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
            ActiveWindow.HidePostBack();
            return UIHelper.Result();
        }
    }
}
